package com.fadis.data.base;


/** 用来实现一个RedisObject 里面可封装各种数据结构
 *  1 Integer(String)
 *  2 List
 *  3 Hash
 *  4 Set
 *  5 Zset
 *
 * **/
public class FadisObject {
    private final static int REDIS_STRING = 2;
    private final static int REDIS_LIST = 3;
    private final static int REDIS_HASH = 4;
    private final static int REDIS_SET = 5;
    private final static int REDIS_ZSET = 6;
    private final static int REDIS_HYPERLOGLOG = 7;

    short encoding; // 编码
    long lru; /* lru time (relative to server.lruclock) */  // 对象最后一次被访问的时间
    int refcount;  // 引用计数

    private int type;
    private IBaseData data;

    // 返回一个RedisObject,参数是String,可能是Integer,或者是普通String
//    static public FadisObject redisStringObject(int type, byte[] data){
//        return new FadisObject(REDIS_STRING,obj);
//    }


    public FadisObject(int type, IBaseData data){
        this.type = type;
        this.data = data;
    }

    public IBaseData getData(){
        return data;
    }

    public int getType() {
        return type;
    }

    //    @Override
//    public int hashCode() {
//        return  (data.hashCode() | (type << 10)) ^ 0x14D54B57;
//    }

    // if other is null, return false
    // if type != other.type || !data.equals(other.data), return
//    @Override
//    public boolean equals(Object obj){
//        FadisObject other = (FadisObject) obj;
//        if( !super.equals(other)){
//            return false;
//        }
//
//        if(type != other.type || !data.equals(other.data)){
//            return false;
//        }
//
//        return true;
//    }
}


